package ThreadSafeShareAnswer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2022-11-23
 * Time: 14:00
 */
public class ShareAnswer1 {
    public static int counter = 0;
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            for(int i =0;i<5000;++i){
                counter++;
            }
        });
        Thread t2 = new Thread(()->{
            for(int i =0;i<5000;++i){
                counter--;
            }
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(counter);
    }
}
